#include "PAP_defs.h"

// The following prescaler values are only valid when working with the
// internal LPO or the internal reference. If the external referece is going
// to be used, then the values should be recalculated

//#define RTC_LARGE_PRESCALERS

#ifdef RTC_LARGE_PRESCALERS

    #define RTC_PRESCALER_OFF       0
    #define RTC_PRESCALER_1024      1
    #define RTC_PRESCALER_2048      2
    #define RTC_PRESCALER_4096      3
    #define RTC_PRESCALER_8192      4
    #define RTC_PRESCALER_16384     5
    #define RTC_PRESCALER_32768     6
    #define RTC_PRESCALER_65536     7
    #define RTC_PRESCALER_1000      8
    #define RTC_PRESCALER_2000      9
    #define RTC_PRESCALER_5000      10
    #define RTC_PRESCALER_10000     11
    #define RTC_PRESCALER_20000     12
    #define RTC_RPESCALER_50000     13
    #define RTC_PRESCALER_100000    14
    #define RTC_PRESCALER_200000    15    

#else

    #define RTC_PRESCALER_OFF   0
    #define RTC_PRESCALER_8     1
    #define RTC_PRESCALER_32    2
    #define RTC_PRESCALER_64    3
    #define RTC_PRESCALER_128   4
    #define RTC_PRESCALER_256   5
    #define RTC_PRESCALER_512   6
    #define RTC_PRESCALER_1024  7
    #define RTC_PRESCALER_1     8
    #define RTC_PRESCALER_2     9
    #define RTC_PRESCALER_4     10
    #define RTC_PRESCALER_10    11
    #define RTC_PRESCALER_16    12
    #define RTC_RPESCALER_100   13
    #define RTC_PRESCALER_500   14
    #define RTC_PRESCALER_1000  15

#endif

#define RTC_INTERRUPTS_ENABLED 1
#define RTC_INTERRUPTS_DISABLED 0

#define RTC_CLK_LPO       0

#ifdef RTC_LARGE_PRESCALERS
    #define RTC_CLK_INTERNAL  3 
#else
    #define RTC_CLK_INTERNAL  2 
#endif

uint8 u8RTC_CheckFlag (void);

void vfnRTC_ClockSelect (uint8 u8clock);

void vfnRTC_InterruptConfig (uint8 u8status);

void vfnRTC_PrescalerSelect (uint8 u8prescaler);

void vfnRTC_SetModulo (uint8 u8modulo);

void vfnRTC_ClearFlag (void);

uint8 u8RTC_ReadCounter (void);

